package com.ly.ql.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ly.ql.Entity.MaterialEntity;
import com.ly.ql.mapper.MaterialMapper;
import com.ly.ql.service.MaterialService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, MaterialEntity> implements MaterialService {

    @Override
    public List<MaterialEntity> selectMaterialEntity() {
        LambdaQueryWrapper<MaterialEntity> queryWrapper =new LambdaQueryWrapper<>();
        queryWrapper.likeLeft(MaterialEntity::getCode,"4");
        System.out.println("成功");
        List<MaterialEntity> materialEntities = this.baseMapper.selectList(queryWrapper);
        if (!materialEntities.isEmpty()){
            return materialEntities;
        }
        return null;
    }

    @Override
    public List<MaterialEntity> selectMaterialByCodeAndWareHouseCode(String code, String wareHouseCode) {
        LambdaQueryWrapper<MaterialEntity> queryWrapper =new LambdaQueryWrapper<>();
        queryWrapper.eq(MaterialEntity::getCode,code);
        List<MaterialEntity> materialEntities = this.baseMapper.selectList(queryWrapper);
        if (!materialEntities.isEmpty()){
            return materialEntities;
        }
        return null;
    }

}
